package com.bianguo.android.iocdemo.view.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bianguo.android.iocdemo.view.widget.parallax.ParallaxInflater;

import java.util.ArrayList;

public class ParallaxFragment extends Fragment {

    private ArrayList<View> parallaxView;

    public static ParallaxFragment newInstance(int layoutId) {

        Bundle args = new Bundle();
        args.putInt("layout_id", layoutId);
        ParallaxFragment fragment = new ParallaxFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        parallaxView = new ArrayList<>();
        Bundle bundle = getArguments();
        int layoutId = bundle.getInt("layout_id");
        ParallaxInflater mInflater = new ParallaxInflater(inflater, getActivity(), this);
        return mInflater.inflate(layoutId, null);
    }

    public ArrayList<View> getParallaxView() {
        return parallaxView;
    }
}
